package com.example.basecommon.utils;

import android.app.Activity;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;

import com.example.basecommon.R;

public class TipsNormalDialog {

    /**
     * @param activity
     * @param title    显示错误类型 例 服务器错误:、网络错误:、
     * @param message
     */
    public void show(Activity activity, String title, String message) {
        final AlertDialog.Builder builer = new AlertDialog.Builder(activity, R.style.base_common_Dialog_Error_Stype)
                .setMessage(message)
                .setTitle(title)
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                })
                .setCancelable(true);
        builer.show();
    }

    public void show(Activity activity, int resTitleId, int resMessageId) {
        final AlertDialog.Builder builer = new AlertDialog.Builder(activity, R.style.base_common_Dialog_Error_Stype)
                .setMessage(activity.getString(resMessageId))
                .setTitle(activity.getString(resTitleId))
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    }
                })
                .setCancelable(true);
        builer.show();
    }

    public  void showOnClick(Activity activity, String title, String message) {
        final AlertDialog.Builder builer = new AlertDialog.Builder(activity, R.style.base_common_Dialog_Error_Stype)
                .setMessage(message)
                .setTitle(title)
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        mListener.onOkClick();
                    }
                })
                .setCancelable(true);
        builer.show();
    }

    public interface OnOkClickListener {
        void onOkClick();
    }

    public  OnOkClickListener mListener;
    public  TipsNormalDialog setOnOKClickListener(OnOkClickListener listener) {
        mListener = listener;
        return this;
    }
}
